import sqlalchemy as sa

from {{{ package_name }}}.models.base import Base, BaseDbModel


class {{{ entity_name }}}(BaseDbModel):
    """{{{ function_name }}}实体"""
    __tablename__ = '{{{ table_name }}}'
    __table_args__ = {
        'comment': '{{{ function_name }}}表',
    }

    {%- for column in columns %}
    {%- if column.column_name not in sub_table_fields %}
    {{{ column.java_field }}} = sa.Column(sa.{{{ model_type_map.get(column.java_type) or column.java_type }}}({% if column.column_length!='0' and column.column_name!='Text' %}{{{column.column_length}}}{% endif %}){% if column.is_pk %}, primary_key=True{% endif %}{% if column.is_increment %}, autoincrement=True{% endif %}{% if column.is_required %}, nullable=False{% endif %}{% if column.column_default %}, server_default=sa.text("{{{column.column_default}}}"){% endif %}, comment="{{{ column.column_comment }}}")
    {%- endif %}
    {%- endfor %}


{{{ entity_snake_name }}} = {{{ entity_name }}}.__table__
